
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gdraw</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>gdraw</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hashao/.FontForge/python/modules/gdraw/gdraw.py">/home/hashao/.FontForge/python/modules/gdraw/gdraw.py</a></font></td></tr></table>
    <p><tt>ctypes&nbsp;wrapper&nbsp;to&nbsp;Attach&nbsp;the&nbsp;GDraw&nbsp;event&nbsp;handler&nbsp;to&nbsp;the&nbsp;gtk&nbsp;main&nbsp;loop.<br>
&nbsp;<br>
Copyright&nbsp;&lt;hashao2@gmail.com&gt;&nbsp;2009<br>
&nbsp;<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;modify<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;as&nbsp;published&nbsp;by<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either&nbsp;version&nbsp;3&nbsp;of&nbsp;the&nbsp;License,&nbsp;or<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;along&nbsp;with&nbsp;this&nbsp;program;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foundation,&nbsp;Inc.,&nbsp;51&nbsp;Franklin&nbsp;Street,&nbsp;Fifth&nbsp;Floor,&nbsp;Boston,<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MA&nbsp;02110-1301,&nbsp;USA.<br>
&nbsp;<br>
We&nbsp;use&nbsp;a&nbsp;gdraw&nbsp;timeout&nbsp;handler&nbsp;to&nbsp;call&nbsp;the&nbsp;gtk.main_iteration()&nbsp;periodically.<br>
&nbsp;<br>
You&nbsp;might&nbsp;also&nbsp;want&nbsp;to&nbsp;copy&nbsp;setup_syspath()&nbsp;in&nbsp;gdraw.py&nbsp;to&nbsp;setup&nbsp;proper<br>
sys.path&nbsp;for&nbsp;fontforge&nbsp;scripts.<br>
&nbsp;<br>
Usage:&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;gdraw&nbsp;import&nbsp;gtkrunner<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;w&nbsp;=&nbsp;gtk.Window()<br>
&nbsp;&nbsp;&nbsp;&nbsp;b&nbsp;=&nbsp;gtk.Button('click')<br>
&nbsp;&nbsp;&nbsp;&nbsp;w.add(b)<br>
&nbsp;&nbsp;&nbsp;&nbsp;w.show_all()<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;gtkrunner.start()<br>
&nbsp;<br>
Example:<br>
&nbsp;&nbsp;&nbsp;&nbsp;t&nbsp;=&nbsp;<a href="#Timer">Timer</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;tid&nbsp;=&nbsp;t.add(timeout,&nbsp;func[,&nbsp;data])<br>
&nbsp;&nbsp;&nbsp;&nbsp;t.remove(t)<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;top&nbsp;start/stop&nbsp;gtk&nbsp;main&nbsp;iteration<br>
&nbsp;&nbsp;&nbsp;&nbsp;g&nbsp;=&nbsp;<a href="#GtkRunner">GtkRunner</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;g.start()<br>
&nbsp;&nbsp;&nbsp;&nbsp;g.stop()</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="gtk.html">gtk</a><br>
</td><td width="25%" valign=top><a href="types.html">types</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="gdraw.html#GtkRunner">GtkRunner</a>
</font></dt><dt><font face="helvetica, arial"><a href="gdraw.html#Timer">Timer</a>
</font></dt></dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="GtkRunner">class <strong>GtkRunner</strong></a></font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;Helper&nbsp;class&nbsp;to&nbsp;start&nbsp;and&nbsp;stop&nbsp;gtk&nbsp;main&nbsp;iteration.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="GtkRunner-__init__"><strong>__init__</strong></a>(self, timer<font color="#909090">=None</font>)</dt></dl>

<dl><dt><a name="GtkRunner-start"><strong>start</strong></a>(self, timeout<font color="#909090">=200</font>)</dt><dd><tt>Process&nbsp;gtk&nbsp;events&nbsp;every&nbsp;some&nbsp;time.</tt></dd></dl>

<dl><dt><a name="GtkRunner-stop"><strong>stop</strong></a>(self)</dt><dd><tt>Stop&nbsp;gtk&nbsp;event&nbsp;handler.</tt></dd></dl>

</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Timer">class <strong>Timer</strong></a></font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;<a href="#Timer">Timer</a>&nbsp;class&nbsp;for&nbsp;everyone&nbsp;else&nbsp;to&nbsp;add&nbsp;timer&nbsp;handler&nbsp;to&nbsp;<br>
gdraw's&nbsp;event&nbsp;loop.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Timer-__del__"><strong>__del__</strong></a>(self)</dt><dd><tt>Cleanup&nbsp;everything.</tt></dd></dl>

<dl><dt><a name="Timer-__init__"><strong>__init__</strong></a>(self)</dt></dl>

<dl><dt><a name="Timer-add"><strong>add</strong></a>(self, timeout, func, data<font color="#909090">=None</font>)</dt><dd><tt>timeout:&nbsp;in&nbsp;millisecond.<br>
frequency:&nbsp;0&nbsp;=&gt;&nbsp;one&nbsp;shot.<br>
func:&nbsp;stop&nbsp;if&nbsp;return&nbsp;false</tt></dd></dl>

<dl><dt><a name="Timer-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Remove&nbsp;all&nbsp;the&nbsp;timers.</tt></dd></dl>

<dl><dt><a name="Timer-is_active"><strong>is_active</strong></a>(self, gtimer)</dt><dd><tt>Test&nbsp;if&nbsp;a&nbsp;given&nbsp;GTimer*&nbsp;is&nbsp;active.</tt></dd></dl>

<dl><dt><a name="Timer-remove"><strong>remove</strong></a>(self, timer)</dt><dd><tt>Remove&nbsp;the&nbsp;give&nbsp;timer.</tt></dd></dl>

<dl><dt><a name="Timer-setup_event_window"><strong>setup_event_window</strong></a>(self)</dt><dd><tt>Setup&nbsp;a&nbsp;gdraw&nbsp;hidden&nbsp;event&nbsp;window&nbsp;to&nbsp;handle&nbsp;timeout&nbsp;events.</tt></dd></dl>

</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__all__</strong> = ['Timer', 'GtkRunner', 'gtkrunner']<br>
<strong>gtkrunner</strong> = &lt;gdraw.GtkRunner instance at 0x9993fac&gt;</td></tr></table>
</body></html>